<?php

$status=array('No activo', 'Activo');
$checkseccion="";
$facadeSetting= new Admin_Model_Facade_Settings();
$baseUrl= $this->baseUrl()."/".$this->module;?>
<div id="submenu-div-top">
    <ul id="submenu-admin-top">
        <li class="active-link"><a href="<?php echo $baseUrl; ?>/settings/viewusers/"><span>:: Usuarios</span></a></li>
        <li><a href="<?php echo $baseUrl; ?>/settings/viewbanners/"><span>:: Banners</span></a></li>
    </ul>
</div>
<div id="div-image-top-overline">              
    <img src="<?php echo $this->baseUrl()?>/css/img/section-users-image-top-line-over.jpg" width="273" height="78" title="" alt="" />
</div>
<div id="line-separator-admin"></div>
<div class="contenido">
    <div id="submenu-underline">
        <div id="div-float-menu_underline">
            <table width="488" id="submenu-underline-table-menu" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="178" height="25" align="left" valign="middle" class="no-clicked">
                        <a href="<?php echo $baseUrl?>/settings/">Crear nuevo usuario</a>
                    </td>
                    <td width="308" align="left" valign="middle" class="clicked">
                        <a href="<?php echo $baseUrl?>/settings/viewusers/">Usuarios existentes</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="content-underline">
        <p>&nbsp;</p>
        <div>
            <ul class="error-li">
                        <?php
                        if(!empty($this->messageError)){
                            foreach($this->messageError as $error){ ?>
                <li><?php echo $error; ?></li><?php       }        }?>
            </ul>
        </div>
        <table border="0" class="blue-bar-user-list" cellpadding="0" cellspacing="0">
            <tr>
                <td class="blue-bar-user-list-left">&nbsp;</td>
                <td valign="middle" align="left" class="blue-bar-user-list-center title-blue-bar-user-list">Nombre de usuario</td>
                <td valign="middle" align="left" class="blue-bar-user-list-center title-blue-bar-user-list">Tipo</td>
                <td valign="middle" align="left" class="blue-bar-user-list-center title-blue-bar-user-list">Email</td>
                <td valign="middle" align="left" class="blue-bar-user-list-center title-blue-bar-user-list">Estado</td>
                <td valign="middle" align="center" class="blue-bar-user-list-center title-blue-bar-user-list">Accesos</td>
                <td valign="middle" align="left" class="blue-bar-user-list-center">&nbsp;</td>
                <td class="blue-bar-user-list-right">&nbsp;</td>
            </tr>
                <?php
                if(is_array($this->Users)){
                    foreach($this->Users as $user){
                        $checkstatus=($user['Status']==1)? 'checked="checked"' : '';?>
            <tr>
                <td height="30">&nbsp;</td>
                <td valign="middle" height="30" valign="middle" align="left" class="username-userlist">
                    <a href="<?php echo $baseUrl?>/settings/?userId=<?php echo $user['Id']; ?>"><?php echo $user['Fullname']; ?></a>
                </td>                    <td valign="middle" height="30" valign="middle" align="left" class="Role-userlist">
                    <?php echo $user['Role']; ?>
                </td>
                <td valign="middle" height="30" valign="middle" align="left" class="Email-userlist">
                    <?php echo $user['Email']; ?>
                </td>
                <td valign="middle" height="30" valign="middle" align="left" class="Status-userlist">
                    <input type="checkbox" name="status-<?php echo $user['Id'];?>" id="status-<?php echo $user['Id'];?>" class="status-user-change" <?php echo $checkstatus; ?> />
                    <label for="status-<?php echo $user['Id'];?>"><?php echo $status[$user['Status']]; ?></label>
                </td>                    <td valign="middle" height="30" valign="middle" align="left"  class="Secciones-userlist">
                    <table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                    <?php foreach($this->Secciones as $secciones) {
                        $checkseccion="";
                        if(is_array($user['Permisions'])){
                            $checkseccion=$facadeSetting->in_array_section($secciones['Id'], $user['Permisions']) ? 'checked="checked"' :'';    }?>
                            <td height="30" valign="middle" align="left" class="Secciones-userlist">
                                <input type="checkbox" name="Seccion-<?php echo $secciones['Id'];?>-<?php echo $user['Id'];?>" id="Seccion-<?php echo $secciones['Id'];?>-<?php echo $user['Id'];?>" class="sections-user-change" <?php echo $checkseccion; ?> />
                                <label for="Seccion-<?php echo $secciones['Id'];?>-<?php echo $user['Id'];?>"><?php echo substr($secciones['Description'], 0,5); ?></label>
                            </td><?php } ?>
                        </tr>
                    </table>
                </td>
                <td valign="middle" height="30" valign="middle" align="left" class="Delete-userlist">
                    <a href="<?php echo $baseUrl?>/settings/deleteuser/userId/<?php echo $user['Id']; ?>" class="delete-user">Borrar</a>
                </td>
                <td valign="middle" height="30">&nbsp;</td>
            </tr>
                    <?php        }    }?>
        </table>
    </div>
</div>